<template>
	<view class="page">
		<view class="group_2">
			<view class="" style="width: 100%;height: 1rpx;background-color: #dedede;"></view>
			<view class="group_3">
				<view class="flex-space-between">
					<text lines="1" class="text_8">场馆名称</text>
					<view class="item">
						<input type="text" placeholder="请输入场馆名称" />
					</view>
				</view>
				<text lines="1" class="text_8">添加图片</text>
				<view class="" style="margin-top: 40rpx;margin-left: 20rpx;border-bottom: solid 2rpx #efefef;">
					<u-upload  :fileList="fileList1" name="1" width="150rpx" height="150rpx" @afterRead="afterRead"
						@delete="deletePic" multiple :maxCount="4" />
				</view>
				<view class="flex-space-between">
					<text lines="1" class="text_8">场馆描述</text>
					<view class="item">
						<input type="text" placeholder="请输入场馆描述" />
					</view>
				</view>
				<view class="flex-space-between">
					<text lines="1" class="text_8">手机号</text>
					<view class="item">
						<input type="text" placeholder="请输入手机号" />
					</view>
				</view>
				<view class="flex-space-between">
					<text lines="1" class="text_8">姓名</text>
					<view class="item">
						<input type="text" placeholder="请输入姓名" />
					</view>
				</view>
				<view class="flex-space-between">
					<text lines="1" class="text_8">邮箱</text>
					<view class="item">
						<input type="text" placeholder="请输入邮箱" />
					</view>
				</view>
				
				<view style="margin-top: 30rpx;font-weight: 700;font-size: 30rpx;margin-left: 20rpx;">
					请选择续卡套餐
				</view>
				<view class="justify-start flex-wrap d-flex">
					<view class="card" v-for="(item,index) in pointLits" :key="index" @click="gocard(index)"
						:class="[selectcard===index?'card_s':'card']">
						<view class="card_ysj">
							<view v-if="item.zsong != ''" :class="[selectcard===index?'card_ysj_ls':'card_ysj_s']">推荐</view>
						</view>
						<view class="year_r">
							<text>{{item.year}}</text>
						</view>
						<view :class="[selectcard===index?'card_cs_n':'card_cs']">
							<text>{{item.cika}}</text>
							<text :class="[selectcard===index?'card_cs_ss':'card_cs_s']" v-if="item.zsc != ''">+{{item.zsc}}</text>
						</view>
						<view v-if="item.money != ''" :class="[selectcard===index?'card_jec':'card_je']">
							￥{{item.name}}
						</view>
						<view v-if="item.money == ''" :class="[selectcard===index?'card_jec':'card_jes']">
							￥{{item.name}}
						</view>
						<view v-if="item.money != ''" :class="[selectcard===index?'card_hxs':'card_hx']">
							￥{{item.money}}
						</view>
					</view>
				</view>
				
				<view class="flex-space-between">
					<text lines="1" class="text_8">许可开始时间</text>
					<view class="item">
						<input type="text" placeholder="请填写开始时间" @click="show = true" disabled v-model='datatime'/>
					</view>
				</view>
				<view class="flex-space-between">
					<text lines="1" class="text_8">许可结束时间</text>
					<view class="item">
						<input type="text" placeholder="自动计算生成" disabled/>
					</view>
				</view>
				
				<view class="" style="width: 100%;height: 20vw;"></view>
				<u-datetime-picker :show="show" v-model="value1" mode="datetime" @cancel="show = false" :minDate="-845628841" :maxDate="2856778555000"
					@confirm="confirmclick()"></u-datetime-picker>
			</view>
			
			<view class="" style="position: fixed;width: 100%;height: 16vw;background-color: #fff;z-index: 999;bottom: 0;">
				<button class="button_3" @click="onClick">
					支付并申请
				</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				value1: Number(new Date()),
				datatime:'',
				fileList1: [],
				url_phone: '',
				pointLits: [{
						id: '1',
						name: '200.00',
						cika: '票卡',
						money: '300.00',
						zsong: 20,
						zsc: '订场',
						year:'一年'
					},
					{
						id: '2',
						name: '300.00',
						money: '400.00',
						cika: '票卡',
						zsong: '',
						zsc: '订场',
						year:'二年'
					}
				],
				selectcard: 0
			}
		},
		onLoad() {

		},
		methods: {
			gocard(index) {
				this.selectcard = index
			},
			confirmclick(value) {
				this.show = false
				let date = new Date(value.value);
				//时间戳为10位需*1000，时间戳为13位的话不需乘1000
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM; //月补0
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d; //天补0
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h; //小时补0
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m; //分钟补0
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s; //秒补0
				console.log(y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s)
				this.datatime = y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
				return y + '-' + MM + '-' + d; //年月日
				return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s; //年月日时分秒
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: this.url_phone
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'https://sass-test.doit10019.com/api/upload/uploadOneImage', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							// user: 'test',
							project_id: getApp().globalData.projectId,
							app_id: this.$https.weixinAppId,
			
						},
						success: (res) => {
							let result = JSON.parse(res.data);
							this.url_phone = result.data.url
							setTimeout(() => {
								resolve(this.url_phone)
							}, 1000)
						}
					});
				})
			},
			onClick() {
			
			},
		
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		width: 100%;
		height: 100vh;
		background-color: #dedede;

		.group_3 {
			background-color: rgba(255, 255, 255, 1.000000);
			width: 710rpx;
			height: 100vh;
			display: flex;
			flex-direction: column;
			margin: 20rpx 0 0 20rpx;

			.item {
				// padding: 29rpx 30rpx 30rpx;
				padding: 25rpx 30rpx 20rpx 30rpx;
				text-align: right;
				font-size: 28rpx;

				.item-title {
					color: rgb(153, 153, 153);
					font-size: 28rpx;
					font-weight: 500;
					margin-bottom: 20rpx;
				}

				.value {
					color: rgb(51, 51, 51);
					font-size: 28rpx;
					font-weight: 500;
				}

				.time-cell {
					color: rgb(51, 51, 51);
					font-size: 28rpx;
					font-weight: 500;
					justify-content: flex-start;

					.time {
						width: 49%;

						&:last-of-type {
							margin-left: 20rpx;
						}
					}
				}

				.week-list {
					display: grid;
					grid-template-columns: repeat(5, 1fr);
					grid-gap: 20rpx;
					position: relative;

					.week-item {
						padding: 15rpx 0;
						background-color: rgb(243, 243, 243);
						border-radius: 5rpx;
						text-align: center;
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						font-weight: 500;
						border: solid 2rpx transparent;
						box-sizing: border-box;
					}

					.active {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;

						// &:before {
						// 	display: block;
						// 	content: '';
						// 	position: absolute;
						// 	width: 27rpx;
						// 	height: 28rpx;
						// 	right: -2rpx;
						// 	bottom: -2rpx;
						// 	background-image: url("https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/46b1cc85fcb0fd76095daf823b7d2bb4a3235519.png");
						// 	background-repeat: no-repeat;
						// 	background-size: 100%;
						// }
					}

					.active1 {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;
					}

					.active2 {
						color: rgba(255, 98, 0, 1);
						background-color: rgba(255, 65, 5, 0.1);
						// border: solid 2rpx rgb(99, 93, 247);
						position: relative;
					}

					.check {
						color: rgb(51, 51, 51);
						font-size: 24rpx;
						position: absolute;
						bottom: 10rpx;
						right: 0;
					}
				}
			}
			
			.card {
				width: 30%;
				height: 250rpx;
				border: 1rpx #FF0000 solid;
				border-radius: 10rpx;
				margin-top: 30rpx;
				margin-left: 16rpx;
				background-color: #ffffff;
				box-shadow: 0rpx 13rpx 57rpx 0rpx rgba(8,73,162,0.11);
			}
			
			.card_s {
				width: 30%;
				height: 250rpx;
				background-color: #fcd2be;
				// background: linear-gradient(0deg, rgba(255,64,64,0.96), rgba(255,64,64,0.7), rgba(250,142,142,0.93));
				border-radius: 10rpx;
				margin-top: 30rpx;
				margin-left: 16rpx;
				color: #ffffff !important;
				border: none;
			}
			
			.card_hx {
				text-decoration: line-through;
				color: #999999;
				font-size: 22rpx;
				text-align: center;
				margin-top: 5rpx;
			}
			
			.card_hxs {
				text-decoration: line-through;
				color: #999999;
				font-size: 22rpx;
				text-align: center;
				margin-top: 5rpx;
			}
			.year_r{
				font-size: 24rpx;
				text-align: center;
				color:#FF0000;
				margin-top: 5rpx;
			}
			
			.card_ysj {
				width: 30%;
				height: 40rpx;
				color: #ffffff;
				// background-color: rgb(255, 255, 255);
				font-size: 20rpx;
				text-align: center;
				border-radius: 10rpx 0 10rpx 0;
			}
			
			.card_ysj_s {
				width: 100%;
				height: 30rpx;
				background-color: #FF0000;
				// background: linear-gradient(0deg, #ff829f, #FF6884, #FF6884, #FC396B);
				border-radius: 10rpx 0 10rpx 0;
			}
			
			.card_ysj_ls {
				width: 100%;
				height: 30rpx;
				background-color: #FF0000;
				// background: linear-gradient(0deg, #ff829f, #FF6884, #FF6884, #FC396B);
				border-radius: 10rpx 0 10rpx 0;
			}
			
			.card_cs {
				font-size: 24rpx;
				text-align: center;
				color: #FF6200;
				margin-top: 5rpx;
			}
			
			.card_cs_n {
				font-size: 24rpx;
				text-align: center;
				color: #FF0000;
				margin-top: 5rpx;
			}
			
			.card_cs_s {
				color: #FF0000;
			}
			
			.card_cs_ss {
				color: #FF0000;
			}
			
			.card_je {
				font-size: 36rpx;
				color: #FF4105;
				text-align: center;
				margin-top: 5rpx;
				font-weight: 700;
			}
			
			.card_jec {
				font-size: 36rpx;
				color: #FF0000;
				text-align: center;
				margin-top: 5rpx;
				font-weight: 700;
			}
			
			.card_jes {
				font-size: 36rpx;
				color: #FF0000;
				text-align: center;
				margin-top: 5rpx;
			}
			
			.text-blue {
				font-size: 24rpx;
				color: #2f75fa;
				text-align: center;
			}
		}

		.button_3 {
			width: 90%;
			height: 80rpx;
			position: absolute;
			bottom: 20rpx;
			background: linear-gradient(0deg, rgba(214, 53, 53, 0.9), rgba(255, 64, 64, 0.93), rgba(250, 142, 142, 0.93));
			border-radius: 80rpx 80rpx;
			margin-left: 5%;
			color: rgba(255, 255, 255, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
		}
		.text_8 {
			width: 95rpx;
			height: 30rpx;
			overflow-wrap: break-word;
			color: rgba(136, 136, 136, 1);
			font-size: 28rpx;
			font-family: PingFang-SC-Medium;
			font-weight: 500;
			text-align: left;
			white-space: nowrap;
			line-height: 30rpx;
			margin: 0 0 0 19rpx;
		}
	}
</style>